<html>
<head><meta charset="utf-8"><title>Link between expansions and definitions · t-compiler/wg-incr-comp · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/index.html">t-compiler/wg-incr-comp</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Link.20between.20expansions.20and.20definitions.html">Link between expansions and definitions</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241430681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Link%20between%20expansions%20and%20definitions/near/241430681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Link.20between.20expansions.20and.20definitions.html#241430681">(Jun 03 2021 at 18:12)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> I am trying to understand what are the goal of <code>expansion_that_defined</code> and <code>parent_module_of_macro_def</code>. What are the goals of those functions? Are they tracked for incr. comp. in any way? Should they be?</p>



<a name="241433604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Link%20between%20expansions%20and%20definitions/near/241433604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Link.20between.20expansions.20and.20definitions.html#241433604">(Jun 03 2021 at 18:35)</a>:</h4>
<blockquote>
<p>Are they tracked for incr. comp. in any way?</p>
</blockquote>
<p>No idea.</p>



<a name="241433772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Link%20between%20expansions%20and%20definitions/near/241433772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Link.20between.20expansions.20and.20definitions.html#241433772">(Jun 03 2021 at 18:36)</a>:</h4>
<blockquote>
<p>Should they be?</p>
</blockquote>
<p>Well, probably yes.<br>
If values returned by these function change, then results of type-based name resolution may change as well.</p>



<a name="241434469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Link%20between%20expansions%20and%20definitions/near/241434469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Link.20between.20expansions.20and.20definitions.html#241434469">(Jun 03 2021 at 18:42)</a>:</h4>
<blockquote>
<p>I am trying to understand what are the goal of expansion_that_defined and parent_module_of_macro_def.</p>
</blockquote>
<p>The main idea is that name resolution performed during type checking (things like <code>Type::assoc_item</code> or <code>object.method</code>) is performed hygienically with macros 2.0, in the same way as name resolution performed during the main resolution pass that is run earlier.<br>
For that we need to keep some hygiene data around, e.g. for resolving a name using def-site hygiene we need to know location of a macro that produced that name (to try resolving the name at that location).</p>



<a name="241434646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Link%20between%20expansions%20and%20definitions/near/241434646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Link.20between.20expansions.20and.20definitions.html#241434646">(Jun 03 2021 at 18:44)</a>:</h4>
<p>That's the idea, but the current implementation may be somewhat sketchy and I don't remember its details right now.</p>



<a name="241437812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Link%20between%20expansions%20and%20definitions/near/241437812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Link.20between.20expansions.20and.20definitions.html#241437812">(Jun 03 2021 at 19:07)</a>:</h4>
<p>Thank you.<br>
I think the regression in <a href="https://github.com/rust-lang/rust/issues/85153">#85153</a> comes from an over-pessimistic invalidation of dependents of those two functions. Since they are directly called from typeck, compile_codegen_unit... those expensive queries had to be recomputed every time.<br>
I'd like to querify them. However, <code>ExpnId</code> cannot be recovered from a fingerprint, so the query cannot be marked green if it has not been invoked manually.<br>
Since this is an existing bug, we could let it fly, but this makes me slightly uncomfortable.</p>



<a name="241455430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Link%20between%20expansions%20and%20definitions/near/241455430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Link.20between.20expansions.20and.20definitions.html#241455430">(Jun 03 2021 at 21:16)</a>:</h4>
<p>The (somewhat) good news is that these functions only have effect on unstable kinds of macros, so all possible bugs are limited to nightly.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>